package com.efast.dmom.mes.service.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.efast.dmom.mes.bean.WmsOrderLog;
import com.efast.dmom.mes.bean.WmsOutWarehouseOrder;
import com.efast.dmom.mes.bean.WmsPurchaseOrderLog;
import com.efast.dmom.mes.dao.entity.WmsOrderLogDao;
import com.efast.dmom.mes.dao.entity.WmsPurchaseOrderLogDao;
import com.efast.dmom.mes.service.WmsPurchaseOrderHistoryService;
import com.efast.dmom.mes.util.ServiceBaseEntityUtil;
import com.efast.dmom.mes.util.WmsOrderLogStatus;
@Service
public class WmsPurchaseOrderHistoryServiceImpl implements WmsPurchaseOrderHistoryService {

	@Autowired
	private WmsOrderLogDao wmsOrderLogDao;
	@Autowired
	private WmsPurchaseOrderLogDao wmsPurchaseOrderHistoryDao;
	@Override
	public void save(WmsPurchaseOrderLog wmsPurchaseOrderHistory) {
		wmsPurchaseOrderHistoryDao.save(wmsPurchaseOrderHistory);

	}
	@Override
	public void saveOutWarehouseLog(List<WmsOutWarehouseOrder> wmsOutWarehouseOrder,String LogStatus) {
		List<WmsOrderLog> list = new ArrayList<WmsOrderLog>();
		wmsOutWarehouseOrder.forEach(item -> {
			WmsOrderLog wmsOrderLog = new WmsOrderLog();
			ServiceBaseEntityUtil.setUpdateLogEntityData(wmsOrderLog);
			wmsOrderLog.setOrderNo(item.getOutWarehouseOrder());
			wmsOrderLog.setOrderOperationStatus(LogStatus);
			wmsOrderLog.setOrderId(item.getId());
			list.add(wmsOrderLog);
		});
		// 保存出库日志信息
		wmsOrderLogDao.batchSave(list);
	}
	@Override
	public void saveOutWarehouseLog(WmsOutWarehouseOrder wmsOutWarehouseOrder,String LogStatus) {
		List<WmsOrderLog> list = new ArrayList<WmsOrderLog>();
		WmsOrderLog wmsOrderLog = new WmsOrderLog();
		ServiceBaseEntityUtil.setSaveBaseEntityData(wmsOrderLog);
		ServiceBaseEntityUtil.setUpdateBaseEntityData(wmsOrderLog);
		wmsOrderLog.setOrderNo(wmsOutWarehouseOrder.getOutWarehouseOrder());
		wmsOrderLog.setOrderOperationStatus(LogStatus);
		wmsOrderLog.setOrderId(wmsOutWarehouseOrder.getId());
		list.add(wmsOrderLog);
		// 保存出库日志信息
		wmsOrderLogDao.batchSave(list);
	}
	

}
